Screen contents of videos may contain sharp edges of the objects, background with simple colors, many texts, fonts, and thin lines. Screen contents of videos that are artificially generated or have been processed could be quite different in characteristics relative to contents of videos which are naturally captured by a camera as such videos may contains rich colors and complex shapes. Consequently, palette coding was proposed to encode and decode screen contents efficiently. A major color table with a limited and fixed size as well as a coded index map could be signaled to a decoder. When the quantization parameter (QP) is high or is under a low bit rate coding condition, the major color table would usually contain all the colors in a current coding unit (CU).
The major color table could be generated and signaled as a dictionary, a code book or a look up table for reference. The major color table may be includes all colors in the current CU. Since there is a limitation for the size of the major color table, colors not selected into the major color table will be represented by escape colors. Colors that are not covered by the major color table would be signaled as escape colors.
In a conventional palette coding scheme, an escape color pixel could be signaled with a mode flag plus a last index in major color table along with 24 bits YUV/RGB color sample values. However, the limited and fixed size of major color table doesn't always work well when the QP is low for high quality coding and lossless coding. In general, when low QP value or lossless coding is implemented, the occurrence of escape colors would be quite high. However, if escape colors would appear many times in a CU, the frequent occurrences of escape colors could make the current signaling scheme very inefficient. The technical details of the aforementioned predicament are further illustrated in FIG. 1 and FIG. 2 and explained in their corresponding written descriptions.
FIG. 1 illustrates a general method color palette coding by using a three index coding mode. In step S101, pixels of a coding block 101 would be analyzed in terms of various colors and the probabilities of their occurrences. In detail, FIG. 1 shows a color sample which includes not limited to 16 pixels, and the colors represented are red (R), pink (Pk), blue (B), light blue (LB), green (G), yellow (Y), and black (Bk). The occurrences of these colors are compiled in a manner similar to a histogram 102. In the example of FIG. 1, the occurrences for R, P, B, LB, G, Y, and BK are 4, 3, 3, 2, 2, 1, and 1 respectively.
In step S102, quantization would be performed to translate from the histogram into a major color index table 103 based on the order of the probability of their occurrences. Afterwards, the color of a pixel would subsequently be referred to by its index. In the example of FIG. 1, index number 0 would refer to the color red (R), index number 1 would refer to the color blue (B), index number 2 would refer to the color green (G), and so forth. In step S103, the colors of each pixel of the color sample 101 would be represented by an index map 104 which could be stored temporarily in a video buffer, saved permanently in a disk drive, or transmitted to a video driver to be shown in a video display.
FIG. 2 illustrates a general method color palette coding by using a three index coding mode through an encoded syntax. In order to encode the colors of a color sample 101, a syntax would be use to represent the colors of the color sample 101. In the sample of FIG. 2, the syntax may include not limited to a copy run mode flag (e.g., 210), a major color index (e.g., 211), and optionally an original color value (e.g., 212) only if the color to be represented is an escape color which is not one of the colors listed in the major color table 220. For example, assuming that the major color table is 5 bits, if the color of a pixel is orange (O), it would be index 0 of the major color table 220 represented by the binary sequence of ‘00000’; if the color of a pixel is blue (B), it would be indexed as 1 represented by the binary sequence of ‘00001’; and so forth.
The steps of palate coding of FIG. 2 would be implemented as follows. In step S200, the copy left run mode or the copy above run mode would be determined according to the binary value of the copy run mode flag 210. In step S202, assuming that the copy above run mode is to be implemented, then the copy run mode flag 210 would be set accordingly with an associated run value. Otherwise, in step S201, assuming that the copy left run mode is to be implemented, then copy run mode flag 210 would set as a copy left run mode. The syntax would then include not limited to a major color index with an associated run value if the color to be represented can be exactly represented by the major color table 220. In other words, the color to be represented exactly matches one of the colors of the major color table 220; otherwise, if the color cannot be accurately represented by the major color table 200, the color would be represented as an escape color. In step S203, assuming that the color is an escape color, the syntax would include not limited to the (last) index 211 of the major color table 220 (e.g., the color “escape” of index 31) and an original color value 212. In the same of FIG. 2, assuming that E1 is the color grey which is an escape color, the syntax would include not limited to the copy run mode flag 210 set as ‘0’, the major color index 211 set as the value 31 or ‘11111’, the original color value 212 could be set as ‘1111111 1111111 1111111’ as an example. However, the disclosure does not limit the representation of an original color to be 24 bits nor the exact binary sequences.
If a high resolution color sample is to be encoded, many color samples would be slightly different from the major colors especially for high rate coding conditions such that many color samples could not be accurately represented. If many escape color pixels have to occur more than once in a color sample, it can be seen from FIG. 1 and FIG. 2 that a coding syntax cannot be efficiently encoded, since the length of a binary sequence to represent an original color value 212 is much longer than the length of a binary sequence to represent a major color index. Therefore, an alternative method of color palette coding and an electronic device using the same method from the currently established method could be proposed.